﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XT.Model;
using XT.Repository;

namespace XT.BusinessService
{
    

    public class RoomReviewService : IRoomReviewService
    {
        private readonly IUow _uow;
        public RoomReviewService(IUow uow)
        {
            _uow = uow;
        }

        public IEnumerable<Room_Review> getReviews(int idRoom)
        {
            return _uow.RoomReviewRepo.FindAllByCriteria<Room_Review>((c => c.Room_Id.Equals(idRoom)), o => o.OrderByDescending(c => c.Id));
        }

        public int AddRoomReview(Room_Review reviewneedsave)
        {
            try
            {
                reviewneedsave.Review_Date = DateTime.Now;
                _uow.RoomReviewRepo.Add(reviewneedsave);
                return 1;
            }
            catch
            {
                return -1;
            }
        }
 
    }
}
